package com.edou.cms.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.cms.dao.ICmsColumnTagDao;
import com.edou.cms.entity.CmsColumnTag;
import com.edou.cms.service.ICmsColumnTagService;

import com.edou.cms.dto.CmsColumnTagCondition;

@Service("cmsColumnTagServiceImpl")
@Transactional(value = "transactionManager")
public class CmsColumnTagServiceImpl implements ICmsColumnTagService{

	@Resource(name = "cmsColumnTagDaoImpl")
	private ICmsColumnTagDao cmsColumnTagDao;

	/**
	 * 分页查询
	 * @param pageResult 分页对象
	 * @param condition 查询条件类
	 */
	public void listCmsColumnTagByPage(PageResult<CmsColumnTag> pageResult,CmsColumnTagCondition condition){
		int rows = cmsColumnTagDao.listCmsColumnTagByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<CmsColumnTag> list = cmsColumnTagDao.listCmsColumnTagByPage(rowBounds,condition);
		pageResult.setResult(list);
	}
	
	/**
	 * 根据栏目id查询栏目标签
	 * @param columnId
	 * @return
	 */
	public List<CmsColumnTag> listColumnTagByColumnId(String columnId) {
		return cmsColumnTagDao.listColumnTagByColumnId(columnId);
	}

	/**
	 * 根据ID查询
	 * @param id 主键
	 * @return 文章标签关联表
	 */
	public CmsColumnTag getCmsColumnTagById(String id){
		return cmsColumnTagDao.getCmsColumnTagById(id);
	}

	/**
	 * 新增
	 * @param item 文章标签关联表
	 */
	public void add(CmsColumnTag item){
		cmsColumnTagDao.add(item);
	}

	/**
	 * 修改
	 * @param item 文章标签关联表
	 */
	public void update(CmsColumnTag item){
		cmsColumnTagDao.update(item);
	}

	/**
	 * 根据ID集合批量删除
	 * @param ids ID集合
	 */
	public void delByIds(String[] ids){
		cmsColumnTagDao.delByIds(ids);
	}
}

